<?php


class DB
{
    private static $db_str = 'mysql:dbname=test;host:127.0.0.1';
    private static $user =  'root';
    private static $pass = '';

    /**存储对象*/
    private static $obj = null;
    public function __construct()
    {

    }
    /**获取对象
     * @author crazy
     * @time 2018-03-17
     */
    public function getObj()
    {
        if(self::$obj === null){
            $pdo = new PDO(self::$db_str,self::$user,self::$pass);
            self::$obj = $pdo;
        }
        return self::$obj;
    }

    /**获取列表
     * @param $sql
     * 查询语句
     */
    public function getList($sql=''){
        $list = self::$obj->query($sql);
       return $list->fetchAll();
    }


}







